#################################################################
#@Program: xrtdb -> Cambada soccer robots configuration files	#
#		automatic generator				#
#@Authors: Tiago Nunes Mec 37161				#
#	   Milton Gregório Mec 36275				#
#	   David Ferreira Mec 36129				#
#@Year: 2007							#
#@Univ: Universidade de Aveiro					#
#@File: Makefile 						#
#@Description: Makefile with all the options necessary to	#
#		compile the xrtdb executable and clean all the	#
#		mess						#
#################################################################

#Variable definition
CC = gcc
CFLAGS = -Wall -O3
OBJS = xrtdb.o xrtdb.tab.o rtdb_errors.o rtdb_functions.o rtdb_ini_creator.o rtdb_user_creator.o 
RM = /bin/rm -f
EXENAME = ../../bin/xrtdb

#Default rule to compile and link everything
all:	$(EXENAME)

#Rule to compile the main program executable
$(EXENAME):	$(OBJS)
		$(CC) $(CFLAGS) $(OBJS) -o $(EXENAME)

#Rules with the object files dependencies
xrtdb.o:	xrtdb.c rtdb_configuration.h rtdb_errors.c rtdb_errors.h rtdb_structs.h rtdb_functions.c rtdb_functions.h rtdb_user_creator.c rtdb_user_creator.h rtdb_ini_creator.c rtdb_ini_creator.h

xrtdb.tab.o:	xrtdb.tab.c xrtdb.tab.h

rtdb_errors.o:	rtdb_errors.c rtdb_errors.h

rtdb_functions.o:	rtdb_functions.c rtdb_functions.h rtdb_configuration.h rtdb_errors.c rtdb_errors.h rtdb_structs.h

rtdb_ini_creator.o:	rtdb_ini_creator.c rtdb_ini_creator.h rtdb_configuration.h rtdb_structs.h

rtdb_user_creator.o:	rtdb_user_creator.c rtdb_user_creator.h rtdb_configuration.h rtdb_structs.h

#Rule to generate the xrtdb.c code file using flex
xrtdb.c:	xrtdb.lex xrtdb.tab.h xrtdb.tab.c rtdb_errors.h
		flex -oxrtdb.c xrtdb.lex

#Rule to generate the xrtdb.tab.c and the xrtdb.tab.h files using bison
xrtdb.tab.c xrtdb.tab.h:	xrtdb.y
				bison -d xrtdb.y

#Rule to clean all the object files generated and the xrtdb.c code file generated by flex
clean:
	$(RM) $(OBJS) xrtdb.c xrtdb.tab.c xrtdb.tab.h
		rm -f rtdb_size.tmp rtdb_sizeof_tmp.c rtdb_sizeof_tmp
	$(RM) $(EXENAME)

# EOF: Makefile
